package com.eight.student.controller;

import com.eight.common.utils.OssUtil;
import com.eight.student.service.MemberService;
import com.eight.student.vo.MemberVo;
import com.eight.student.vo.MemberVo2;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.eight.common.pojo.TbMember;
import com.eight.common.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.websocket.server.PathParam;

/**
 * @program: educaion-parent
 * @description:
 * @author: 平家祥
 * @create: 2023-05-26 15:58
 **/
@RestController
@RequestMapping("/student/member")
@Api(tags = "学员列表")
public class MemberController {
    @Autowired
    MemberService service;


    @ApiOperation("学生列表")
    @PostMapping("/getStudentAll/{currentPage}/{pageSize}")
    public Result getStudentAll(@PathVariable Integer currentPage,
                                @PathVariable Integer pageSize,
                                @RequestBody MemberVo memberVo){
        System.out.println(memberVo);
        System.out.println(memberVo.getGmtCreate()+"~~~~~~~~~~~");
        Page<TbMember> all = service.findAll(currentPage, pageSize, memberVo);
        return Result.success(all);

    }
    @ApiOperation("改变状态")
    @PostMapping("stateChange/{isDisabled}/{id}")
    public Result stateChange(@PathVariable Integer isDisabled,@PathVariable String id){
        Integer i = service.UpdateById(isDisabled,id);
        if (i>0){
            return Result.success();
        }else {
            return Result.fail();
        }
    }
    /**
     *  修改数据
     */
    @ApiOperation("修改数据")
    @PostMapping("/modifyStudentInformation")
    public Result modifyStudentInformation(@RequestBody MemberVo2 memberVo2){
        Integer i = service.update(memberVo2);
        if (i>0){
            return Result.success();
        }else {
            return Result.fail();
        }

    }

}
